package com.hl.ui;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.hl.R;
import com.hl.adapter.ReservAdapter;
import com.hl.app.XiaoMiApplication;
import com.hl.bean.ReservBean;
import com.hl.util.LogUtils;

public class ReservallView {
	private ReservActivity activity;
	private View view;
	private ListView lv;
	private ReservAdapter adapter;

	public ReservallView(final ReservActivity activity) {
		super();
		this.activity = activity;

		view = activity.getLayoutInflater().inflate(R.layout.item_order_list,
				null);
		initView();
		lv.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1,
					int position, long id) {
				// TODO Auto-generated method stub
				LogUtils.i("info", "" + position);
				ReservBean reserv = adapter.getItem(position);
				Intent intent = new Intent();
				intent.setClass(activity, ReservDetailsActivity.class);
				intent.putExtra("reserv", reserv);
				activity.startActivity(intent);
				activity.finish();
			}
		});
	}

	public View getView() {
		// TODO Auto-generated method stub
		return view;
	}

	private void initView() {
		// TODO Auto-generated method stub
		lv = (ListView) view
				.findViewById(R.id.activity_center_myorder_listview_notuserorder);
		adapter = new ReservAdapter(
				XiaoMiApplication.getInstance().alllist_reserval, activity);
		lv.setAdapter(adapter);
	}
}
